<?php
//處理商家登陸操作
InitGP(array("action","commit","suppliersname","supplierspassword"),'GP',1); //初始化變量全局返回
scheckauth();//實時監測用戶是否登錄狀態
if(!empty($_SUSERS['sid'])) {
	dheader("s.php?action=bond");//php跳轉頁面
	exit;
}
if (!empty($commit) && $action="login") {
	//處理登錄操作
	if (empty($suppliersname)||empty($supplierspassword)) {
		showmessage("商家名稱和密碼不能為空！","-1",false);
	}
	$row = $db->fetch_first("Select * From {$tablepre}suppliers where name like '$suppliersname' ");
	if(is_array($row))
	{
		if($supplierspassword != $row['pwd'])
		{
			showmessage("商家名稱和密碼錯誤！","-1",false);
			exit;
		}else 
		{
			$suppliersauth=$row['sid']."\t".$suppliersname."\t".$row['pwd'];
			set_cookie('suppliersauth',cookie_authcode($suppliersauth,'ENCODE'),time()+3600*24);	//設置一天cookie有效期	
			showmessage("登錄成功！","s.php?action=bond");
		}
		
	}else{
		showmessage("商家名稱不存在！","-1",false);
	}
	
}

include template('suppliers_login');//包含輸出指定模板
?>